//<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

function showLogin()
{
	showDialog("#logindialog");
}


window.showDialog = function(selector)
{
	var dlg = selector;
	if(selector.constructor === String)
		dlg = $(selector);

	// 点击关闭时，关闭对话框
	$(".close", dlg).click(function(){
		dlg.hide(); // Closure 闭包
	});

	dlg.show();
}

function login()
{
	var user = {};
	user.username = $("#name").val().trim();
	user.password = $("#pwd").val().trim();
	$.ajax({
		type:"POST",
		url:"",
		data:JSON.stringify(user),
		dataType:'json',
		success:function (resp) {
			if(resp.code!=0)
			{
				alert(resp.reason);
			}
			else {
				self.location="活动中心.html";
				// if (resp.data === "admin")
				// 	self.location = "main_admin.html";
				// else if (resp.data === "patient")
				// 	self.location = "main_patient.html"
				// else
				// 	alert("出现未知错误！");
			}
		}
	})
}
